Welcome to the Materials+ML Workshop¶
Day 1 Agenda:¶
- Introductions
- The workshop Online Book
- Installing Python and Jupyter Notebook
- Working with Jupyter Notebooks
- Getting Started with Python
- Python Data Types
Introductions¶
About This Workshop¶
Tentative Week 1 Schedule:¶
Session | Date | Content |
Day 1 | 06/09/2025 (2:00-4:00 PM) | Introduction, Python Data Types |
Day 2 | 06/10/2025 (2:00-4:00 PM) | Python Functions and Classes |
Day 3 | 06/11/2025 (2:00-4:00 PM) | Scientific Computing with Numpy and Scipy |
Day 4 | 06/12/2025 (2:00-4:00 PM) | Data Manipulation and Visualization |
Day 5 | 06/13/2025 (2:00-4:00 PM) | Materials Science Packages, Introduction to ML |
About Python¶


About Jupyter Lab¶
Tutorial: Installing Python and Jupyter Notebook¶
- Install Jupyter Notebook via pip:
pip install --upgrade jupyter
- Install other dependencies (from a requirements.txt file):
pip install -r requirements.txt
Install Workshop Requirements:¶
Make sure you have installed the Python packages needed for this workshop:
Copy the command from cburdine.github.io/materials-ml-workshop/ in the Getting Started section.
pip install -r https://gist.github.com/cburdine/.../requirements.txt
Tutorial: Python Basics¶
- The
print()
function - Arithmetic
- Types in Python
- Commenting your code
- Variables
Exercises: Python Basics¶
- Golden Ratio
- Quadratic Formula
Tutorial: Logic and Flow Control¶
- The Boolean type
- Comparison operators
- Conditional Statements
Exercises: Logic and Flow Control¶
- Classifying Chemical Compounds
Tutorial: Loops¶
- the
while
loop - The
for
loop - Iterating over lists
Exercises: Loops¶
- Fibbonacci Sequence
- Total Word and Character Count
Review¶
The print()
statement¶
The print()
function is useful for printing out values in Python:
In [1]:
print('Hello World!')
Hello World!
Arithmetic¶
Python code can be used to perform basic arithmetic operations:
In [2]:
2 + 2
Out[2]:
4
In [3]:
print( (3 * (20 / 5)**3) - (0.125 * 64**(1/4)) )
191.64644660940672
Commenting your Code¶
- Comments are essential for making code readable:
In [4]:
# print the actual value of pi (to 10 decimal places):
print(3.1415926535)
# print an estimated value of pi using the arctan Taylor expansion:
# pi = 4 * arctan(1) ~ 4*(1 - 1/3 + 1/5 - 1/7 + ...)
print(4 * (1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13))
3.1415926535 3.2837384837384844
Python Types¶
In [5]:
# This evaluates to "7" (int type)
print(4 + 3)
# This evaluates to "7.0" (float type):
print(21 / 3)
7 7.0
In [6]:
type('this is a string')
Out[6]:
str
In [7]:
type(3.14159)
Out[7]:
float
Variables¶
In [8]:
pi_approximation = 3.14 # float variable
number_of_steps = 100 # int variable
name = 'James T. Kirk' # str variable
The Bool type¶
In [9]:
type(True)
type(False)
Out[9]:
bool
In [10]:
x = True
y = False
z = True
x or (y and z)
Out[10]:
True
Comparison Operators¶
In [11]:
x = 0.25
y = 1.23
z = 0.0
# check if x is outside the interval (0,1]:
print((x <= 0) or (1 < x))
False
Conditional Statements¶
In [12]:
numerator = 10.0
denominator = 2.0
quotient = 0.0
# perform division only if the denominator is nonzero:
if denominator != 0:
quotient = numerator / denominator
print(quotient)
5.0
if
/elif
/else
Statements¶
In [13]:
# initialize a numeric value:
value = 100.0
# print out the sign of the value:
if value < 0:
print('Value is negative.')
elif value == 0:
print('Value is zero.')
else:
print('Value is positive.')
Value is positive.
Questions¶
Recommended Online Book Reading:¶
- Python Data Types
- Python Functions and Classes
Bring your questions to our next meeting tomorrow!